<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible"content="IE=8"><!--以IE8模式渲染-->
	<meta http-equiv="X-UA-Compatible"content="IE=7"><!--以IE7模式渲染-->
	<meta http-equiv="X-UA-Compatible"content="IE=9; IE=8; IE=7; IE=EDGE">
	<title>百朋后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="/tp_bypal/Public/css/manage.css" >
</head>

<body>
	<div id="custmainfo">
		<div id="custinfo">
			<table class="list" cellspacing="0" cellpadding="0" >
				<tr>
					<th style="height: 30px;font-size:20px">借款信息</th>
					<th></th>
					<th></th>
					<th></th>
					<th></th>
					<th></th>
				</tr>
				<tr>
					<td>借款编号</td>
					<td><?php echo $data['binfo_borrowid'];?></td>
					<td>首付时间</td>
					<td><?php echo date('Y-m-d H:i:s', $data['binfo_firstpaydate']);?></td>
					<td>商户全称</td>
					<td><?php echo $data['fac_name'];?></td>
				</tr>
				<tr>
					<td>标题</td>
					<td><?php echo $data['borrow_title'];?></td>
					<td>尾款时间</td>
					<td><?php echo date('Y-m-d H:i:s', $data['binfo_finalpaydate']);?></td>
					<td>商户ID</td>
					<td><?php echo $data['borrow_busid'];?></td>
				</tr>
				<tr>
					<td>金额</td>
					<td><?php echo $data['borrow_money'];?></td>
					<td>取消时间</td>
					<td><?php echo $data['borrow_unworktime'];?></td>
					<td>商户认证材料</td>
					<td><input type="button" value="查看" onclick="findfacref(<?php echo $data['borrow_busid'];?>)"></td>
				</tr>
				<tr>
					<td>首付比例</td>
					<td><?php echo $data['trade_perofpay'];?></td>
					<td>剩余分期额度</td>
					<td><?php echo $data['sum']; ?></td>
					<td>商户类别</td>
					<td><?php echo $data['man_type'];?></td>
				</tr>
				<tr>
					<td>借款等级</td>
					<td><?php echo $data['ad_level'];?></td>
					<td>客户ID</td>
					<td><?php echo $data['borrow_custid'];?></td>
					<td>服务分类</td>
					<td><?php echo $data['service_type']; ?></td>
				</tr>
				<tr>
					<td>利率</td>
					<td><?php echo $data['borrow_rate']; ?></td>
					<td>客户姓名</td>
					<td><?php echo $data['cust_name'];?></td>
					<td>联系人</td>
					<td><?php echo $data['fac_contact'];?></td>
				</tr>
				<tr >
					<td>用途</td>
					<td ><?php echo $data['lt_value'];?></td>
					<td>客户电话</td>
					<td><?php echo $data['cust_phone'];?></td>
					<td>联系电话</td>
					<td><?php echo $data['fac_contactphone'];?></td>
				</tr>
				<tr>
					<td>期限</td>
					<td><?php echo $data['borrow_loanperiod']==0?'未选择期限':$data['borrow_loanperiod'];?></td>
					<td>客户认证资料</td>
					<td><input type="button" value="查看" onclick="findcustref(<?php echo $data['borrow_custid'];?>)"></td>
				</tr>

				<tr >
					<td>还款方式</td>
					<td ><?php echo $data['repay_name'];?></td>
					<td>账户余额</td>
					<td><?php echo number_format($data['fund_balance'], 2).'元'; ?></td>
				</tr>
				<tr>
					<td>手续费</td>
					<td><?php echo $data['borrow_extramoney'];?></td>
					<td>查看申请信息</td>
					<td><input type="button" value="GO" onclick="gotoApply(<?php echo $data['binfo_borrowid'];?>)"></td>
				</tr>
				<tr>
					<td>延期月份</td>
					<td><?php echo $data['delay_time']; ?> 月</td>
				</tr>
				<tr>
					<td>延期费用</td>
					<td>
						<?php
 $delay_money = ceil($data['delay_time']*$data['borrow_money']*$data['borrow_rate']/1200); echo $delay_money." 元"; ?>
					</td>
				</tr>
			</table>

			<hr>
			<table class="list" cellspacing="0" cellpadding="0">
				<tr>
					<th style="height: 30px;font-size:20px">还款信息<input type="button" onclick="showdiv()" style="border: 1px solid #eaeaea;background-color:#6D654E;color:#fff;text-align:center;padding: 2px 10px 3px;border-radius: 4px;" value="详细信息"></th>
					<th></th>
					<th></th>
					<th></th>
				</tr>
				<tr>
					<td>已付其他费用</td>
					<td><?php echo $data['other_money'];?></td>
					<td>应还总额</td>
					<td><?php echo $data['total_repay_money'];?></td>
				</tr>
				<tr>
					<td>已还总额</td>
					<td><?php echo $data['sum_period_recovery'];?></td>
					<td>未还总额</td>
					<td><?php echo $data['un_repay_money'];?></td>
				</tr>
				<tr>
					<td>已还本金</td>
					<td><?php echo $data['sum_principal'];?></td>
					<td>未还本金</td>
					<td><?php echo $data['sum_principal2'];?></td>
				</tr>
				<tr>
					<td>已还利息</td>
					<td><?php echo $data['repay_interest'];?></td>
					<td>未还利息</td>
					<td><?php echo $data['sum_interest'];?></td>
				</tr>
			</table>

			<hr>
			<div id="loinfo"style="display: none">
				<div class="headd">还款明细</div>
				<table class="list" cellspacing="0" cellpadding="0">
					<thead>
						<tr>
							<th>期数</th>
							<th>最晚还款日</th>
							<th>应还本金</th>
							<th>应还利息</th>
							<th>手续费</th>
							<th>滞纳金</th>
							<th>实际还款金额</th>
							<th>还款状态 </th>
							<th>操作<input type="hidden" value="<?php echo $data['borrow_busid']; ?>" id="borrowid"></th>
						</tr>
						<?php
 function count_days($a,$b) { $a_dt=getdate($a); $b_dt=getdate($b); $a_new=mktime(12,0,0,$a_dt['mon'],$a_dt['mday'],$a_dt['year']); $b_new=mktime(12,0,0,$b_dt['mon'],$b_dt['mday'],$b_dt['year']); return round(abs($a_new-$b_new)/86400); } foreach ($array_repay_detail as $key => $value) { $zhinajin = 0; $nowtime = time(); $start_date = $value['start_date']; $end_date = $value['end_date']; $repay_date = $value['repay_date']; $repaylast = strtotime("+1 Days",$end_date); $totalmoney = $value['principal'] + $value['interest'] + $value['poundage']; if ($nowtime > $repaylast && $repay_date == '0') { $days = ceil(($nowtime - $end_date)/24/3600)-1; if($days>1 && $days<=30) { $zhinajin = round($days*($totalmoney)*3/1000,2); } elseif($days>30 && $days<=60) { $zhinajin = (30*($totalmoney)*3/1000)+(($days-30)*($totalmoney)*4/1000); } elseif($days>60) { $zhinajin = (30*($totalmoney)*3/1000)+(30*($totalmoney)*4/1000)+(($days-60)*($totalmoney)*5/1000); } else { $zhinajin = 0; } } else { $zhinajin = $zhinajin + $value['demurrage']; } echo "<tr>"; echo "<td>".$value['period_number']."</td>"; echo "<td>".date("Y-m-d",$value['end_date'])."</td>"; echo "<td>".$value['principal']."</td>"; echo "<td>".$value['interest']."</td>"; echo "<td>".$value['poundage']."</td>"; echo "<td>".$zhinajin."</td>"; echo "<td>".$value['period_recovery']."</td>"; if($repay_date == 0) { if($end_date < time() && time() > $repaylast) { echo "<td> 逾期".$days."天</td>"; } else { echo "<td> 正常</td>"; } } else { if(($end_date+86400)<$repay_date && time()>$repaylast) { echo "<td> 逾期".count_days($end_date,$repay_date)."天</td>"; } else { echo "<td> 正常</td>"; } } if($repay_date==0) { if($start_date<time()) { if($value['period_recovery'] == 0) { echo "<td><input type='button' value='还款' onclick='repay(".$value['binfo_id'].",".$value['repay_detail_id'].",".$data['borrow_custid'].",".$totalmoney.")'></td>"; } elseif($data['borrow_stateid'] == 4) { echo "<td>已取消</td>"; } } else { echo "<td>未到还款日期</td>"; } } else { echo "<td>".date("Y-m-d",$repay_date)."</td>"; } echo "</tr>"; } ?>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>

<script TYPE="text/javascript" src="/tp_bypal/Public/js/jquery-1.8.0.min.js"></script>
<script TYPE="text/javascript" src="/tp_bypal/Public/js/common.js"></script>
<script type="text/javascript" src="/tp_bypal/Public/js/jquery.alert.v1.2/jquery.easydrag.js"></script>
<script type="text/javascript" src="/tp_bypal/Public/js/jquery.alert.v1.2/jquery.alert.js"></script>
<script type="text/javascript" src="/tp_bypal/Public/js/ajax.js"></script>
<script type="text/javascript" src="/tp_bypal/Public/js/autocomplete/jquery.autocomplete.min.js"></script>
<script type="text/javascript">
	//	还款信息详情
	function showdiv() 
	{
		if(document.getElementById("loinfo").style.display=="block") 
		{
			document.getElementById("loinfo").style.display="none";
		}
		else
		{
			document.getElementById("loinfo").style.display="block";
		}
	}
	
	//	还款操作
	function repay(binfo_id,repay_detail_id,borrow_custid,money) 
	{
		var flag = confirm("是否确定还款");
		if(flag) 
		{
			var data = {"binfo_id":binfo_id,"repay_detail_id":repay_detail_id,"borrow_custid":borrow_custid,"money":money};
			var url="../../borrow/borrowbusiness/borrowbusiness_detail_repay";
			$.ajax({
				type: "get",
				async: true,
				data: data,
				url: url,
				success: function(d) 
				{
					var dataObj = JSON.parse(d);
					var state = dataObj.state;
					var mes = dataObj.message;
					if(state == 1) 
					{
						alert(mes);
						window.location.reload();
					}
					else 
					{
						alert(mes);
						window.location.reload();
					}
				},
				error: function(e) 
				{
					alert("网络错误，请联系程序员！");
				}
			});
		}
	}

	//	借款申请详情
	function gotoApply(borrowid) 
	{
		window.parent.addTab('借款申请详情','../../borrow/borrowapply/borrowapply_detail?borrow_id='+borrowid);
	}

	//	客户认证资料查看
	function findcustref(cust_id) {
		window.parent.addTab('材料审核','../../materialCheck/materialcheck/materialcheck_list?cust_id='+cust_id);
	}
</script>
</html>